package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.services.IUserService;
import cn.yunhe.services.impl.UserService;
import cn.yunhe.utils.BaseAction;
import com.opensymphony.xwork2.ModelDriven;
import lombok.Data;


@Data
public class LoginAction extends BaseAction implements ModelDriven {
    private User user;
    IUserService iUserService=new UserService();
    public String execute(){
        User user=iUserService.login(getUser().getUname(),getUser().getUpwd());
        if (user!=null){
            getSession().setAttribute("user",user);
            return "success";
        }else {
            return "error";
        }
    }

    @Override
    public Object getModel() {
        if (user==null){
            User user=new User();
        }
        return user;
    }
}
